package com.redhat.auth.domain;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import com.dayatang.domain.ValueObject;

/**
 * 业务系统绑定（值对象）
 * 
 * @author chencao
 * 
 */
@Embeddable
public class BizSystemBinding implements ValueObject {

	public enum Status {
		DISABLED, ENABLED
	}

	/**
	 * 
	 */
	private static final long serialVersionUID = 3373709742481197580L;
	
	@ManyToOne
	@JoinColumn(name = "FK_BIZ_SYSTEM_ID")
	private BizSystem bizSystem;

	@Column(name = "STATUS")
	private Status status;

	public BizSystem getBizSystem() {
		return bizSystem;
	}

	public void setBizSystem(BizSystem bizSystem) {
		this.bizSystem = bizSystem;
	}

	public Status getStatus() {
		return status;
	}

	public void setStatus(Status status) {
		this.status = status;
	}
    
	@Override
	public boolean equals(Object obj) {
		if(obj==null)return false;
		if(obj instanceof BizSystemBinding==false) return false;
		if(obj instanceof BizSystemBinding){
			BizSystemBinding system = (BizSystemBinding)obj;
			if(system.getBizSystem().equals(this.getBizSystem()))return true;
		}
		return false;
	}

	@Override
	public int hashCode() {
		return bizSystem.hashCode();
	}
}
